<nav>
    <?php foreach($tags_all as $key=>$tags): ?>
    <a onclick="show_tag('<?php echo $key; ?>')"><?php echo $key; ?></a>
    <?php endforeach; ?>
</nav>
<script type="text/javascript" charset="utf-8">

$(document).ready(function(){
    show_tag('tag');
});
function show_tag(tag)
{
    $('.main').hide();
    $('#' + tag).show();
}
</script>